﻿using System;
using System.Collections.Generic;
using System.Text;

using Obsidian.Utils;
using Obsidian.Data.Sql;
using Oak.Model;
using Oak.Core.Data;

namespace Oak.Core.Data
{
    public class ActCategoryDA : TreeDA<CoActCategoryInfo>
    {
        internal CoActCategoryInfo InsertArtCat(CoActCategoryInfo cat)
        {
            return base.InsertNode(cat);
        }

        internal CoActCategoryInfo UpdateArtCat(CoActCategoryInfo cat)
        {
            return base.UpdateNode(cat);
        }

        internal CoActCategoryInfo SelectFirst(CoActCategoryQry qry)
        {
            qry.IsPaging.Set(false);
            qry.PageSize.Set(1);
            List<CoActCategoryInfo> list = this.SelectActCatList(qry);
            if (list.Count > 0)
                return list[0];
            else
                return null;
        }

        internal List<CoActCategoryInfo> SelectActCatList(CoActCategoryQry qry)
        {
            CoActCategoryInfo c = new CoActCategoryInfo();
            IDbHandler dbh = c.CreateHandler();
            dbh.SetFields(c.Fields);

            DataReader dr = base.SelectList(dbh, c, qry);
            return dr.ReadList<CoActCategoryInfo>();
        }

    }
}
